package com.parkingspace.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.parkingspace.dao.ComplainMapper;
import com.parkingspace.entity.Complain;
import com.parkingspace.entity.Property;
import com.parkingspace.service.IComplainService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 投诉表 服务实现类
 * </p>
 *
 * @author Gapper
 * @since 2021-05-24
 */
@Service
public class ComplainServiceImpl extends ServiceImpl<ComplainMapper, Complain> implements IComplainService {

    @Resource
    private  ComplainMapper complainMapper;

    @Override
    public IPage getComplainList(Complain complain, Page page) {
        QueryWrapper<Complain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state",0);
        List<Complain> complainList;
        IPage p=null;
        if (complain.getParkingAddress()!=null){
            queryWrapper.like("parking_address",complain.getParkingAddress());
//            complainList = complainMapper.selectList(queryWrapper);
            p = complainMapper.customPageQuery(page, queryWrapper);

        }
        p = complainMapper.customPageQuery(page, queryWrapper);
//        complainList = complainMapper.selectList(queryWrapper);
        return p;
    }

    @Override
    public Complain getComplainById(Complain complain) {

        System.out.println("getComplainById(IMPL)进来了："+complain.getComplainId());

//        QueryWrapper<Complain> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("complain_id",complain.getComplainId());

        Complain complain1 = complainMapper.selectById(complain.getComplainId());

        return complain1;
    }

    @Override
    public boolean updComplainById(Complain complain) {
//        complain.setState(1);
        return  complainMapper.updateById(complain)==1?true:false;
    }
}
